import React from 'react';
import { inject, observer } from 'mobx-react';
import { WeaLocaleProvider, WeaTop, WeaSelect, WeaNewScroll, WeaSlideModal, WeaDatePicker, WeaBrowser, WeaSearchGroup, WeaInput, WeaRightMenu, WeaDialog, WeaTab, WeaFormItem, WeaDropdown, WeaCheckbox, WeaTag, WeaNewScrollPagination } from 'ecCom';
import { Spin, Tooltip, Icon, Button, Row, Col, Modal, message, Menu } from 'antd';
import { WeaTableNew } from "comsMobx";
import { routerShape } from 'react-router';
import * as mobx from 'mobx';
import ViewTree from '../../public/viewtree/ViewTree';
import ViewSort from '../../public/viewsort/ViewSort';
import TagChoiceBox from '../../public/tag/TagChoiceBox'
import TagSelectBox from "../../public/tag/TagSelectBox";
import GoalAdd from './GoalAdd';
import GoalDetail from './GoalDetail';
import GoalOrgShare from './GoalOrgShare';
import GoalImport from './goalimport/GoalImport';
import GoalExport from './goalexport/GoalExport'
import * as Util from "../../util/Util";
const toJS = mobx.toJS;
const getLabel = WeaLocaleProvider.getLabel;
const { ButtonSelect } = WeaDropdown;
const WeaTable = WeaTableNew.WeaTable;
@inject("goalMainStore", "goalCommonStore")
@observer
export default class GoalMain extends React.Component {
    static contextTypes = {
        router: routerShape
    }
    constructor(props) {
        window.addNodeGoal = (goalid) => {
            this.onAddGoal(-2, goalid)
        }
        super(props);
        this.state = {
            periodData: [{
                key: 'period',
                label: getLabel(15386, '周期'),
                options: [
                    { key: "0", selected: false, showname: getLabel(332, '全部') },
                    { key: "1", selected: false, showname: getLabel(19398, '月度') },
                    { key: "2", selected: false, showname: getLabel(17495, '季度') },
                    { key: "3", selected: true, showname: getLabel(17138, '年度') },
                    { key: "4", selected: false, showname: getLabel(390757, '三年') },
                    { key: "5", selected: false, showname: getLabel(390758, '五年') },
                ]
            }],
            statusData: [{
                key: 'status',
                label: getLabel(23247, '状态'),
                options: [
                    { key: "0", selected: false, showname: getLabel(332, '全部') },
                    { key: "1", selected: false, showname: getLabel(1960, '进行中') },
                    { key: "2", selected: false, showname: getLabel(23774, '已完成') },
                    { key: "3", selected: true, showname: getLabel(1981, '已撤销') },
                ]
            }],
            orderData: [//排序字段
                { key: "", selected: false, showname: getLabel(19520, '最后修改时间') },
                { key: "enddate", selected: false, showname: getLabel(741, '结束日期') },
                { key: "principalid", selected: false, showname: getLabel(16936, '责任') },
            ],
            orderByData: [//排序方式
                { key: "asc", selected: false, showname: getLabel(339, '升序') },
                { key: "desc", selected: false, showname: getLabel(340, '降序') },
            ],
            menu: [
                {
                    key: '0',
                    icon: <i className='icon-coms-search' />,
                    content: getLabel(197, '搜索'),
                    onClick: key => this.advanceSearch(),
                },
                {
                    key: '1',
                    icon: <i className='icon-coms-Add-to' />,
                    content: getLabel(82, '新建'),
                    onClick: key => { this.onAddGoal(-2) },
                },
                {
                    key: '2',
                    icon: <i className='icon-coms-leading-in' />,
                    content: getLabel(32935,'导入'),
                    onClick: key => { this.onGoalImport()},
                }
            ],
            dropData: [{ key: '1', show: getLabel(32136, '批量删除') },{ key: '2', show: getLabel(390705, '批量标记') }],
            buttons: [],
            _top: Util.getHeaderObjectHeight(),
            menuid: 1,
            createvisable: false,
            showSearchAd: false,
            iframeSrc: "",
            searchType: ["advanced", "base"],
            slidevisible: false,
            content: "",
            pgid: "", //组织目标点击id
            dropSelectedKey: 1, //顶部批量操作按钮  1批量删除 2批量标记
            tagvisable: false,  //是否显示标签的dailog
            opentagtype:1,  //1批量标记 2单个标记
            selectgoalid:'', //选择的id
            collectParams:{},//收藏
            orgShareVisiable:false,
        }
        this.rowSelection = {
            selectedRowKeys: this.props.goalMainStore.tableSelectedRowKeys,
            onChange: this.onTableSelectChange
        }
    }
    componentWillMount() {//一些初始化请求
        const { goalMainStore, goalCommonStore , condtype, menuid, toptitle } = this.props;
        Util.setWindowKeys(menuid, (toptitle || getLabel(18028, "我的目标")))
        this.setCollection(condtype,(toptitle || getLabel(18028, "我的目标")));
        if (condtype != null && condtype != undefined) {
            goalMainStore.condtype = condtype;
        }
        if (menuid == 2 || menuid == 8) {
            goalMainStore.goalCard({condtype,doback:()=>{
                if(goalMainStore.sortcond == 4){
                    this.setIfreamSrc();
                }else{
                    this.setState({ menuid: condtype , searchType: ["advanced", "base"] });
                }
                goalMainStore.getGoalList({});
                goalCommonStore.setOrgData(condtype,goalMainStore.typeId,goalMainStore.orgId);
            }});
        }else{
            goalMainStore.getGoalList({});
        }
        this.setState({ menuid })
        goalMainStore.getDateList();
      
    }
    componentDidMount() {
        this.props.onRef(this)
    }

    componentWillReceiveProps(newProps) {
        if (this.props.menuid != newProps.menuid) {
            Util.setWindowKeys(newProps.menuid,(newProps.toptitle || getLabel(18028, "我的目标")));
            this.setCollection(newProps.menuid,(newProps.toptitle || getLabel(18028, "我的目标")));
            const { goalMainStore, condtype, goalCommonStore } = newProps;
            const { setSortCond } = goalMainStore;
            if(this.props.condtype == 2 && newProps.condtype != 2 && goalMainStore.sortcond == 4){ //
                setSortCond(3);
            }
            if (condtype != null && condtype != undefined) {
                goalMainStore.condtype = condtype;
            }
            if (condtype == 2 || condtype == 8) { //公司目标 
                setSortCond(3);
                this.setIfreamSrc();
                goalMainStore.goalCard({condtype,doback:()=>{
                    if(goalMainStore.sortcond == 4){
                        this.setIfreamSrc();
                    }else{
                        this.setState({ menuid: condtype , searchType: ["advanced", "base"] });
                    }
                    goalMainStore.getGoalList({}); //菜单切换判断是否更改视图 传menu参数进去判断
                    goalCommonStore.setOrgData(condtype,goalMainStore.typeId,goalMainStore.orgId);
                }});
            } else {
                this.setState({ menuid: condtype, searchType: ["advanced", "base"] });
                goalMainStore.getGoalList({ menu: 1 }); //菜单切换判断是否更改视图 传menu参数进去判断
            }
            this.resetSearchAd();
            goalCommonStore.setCondtype(condtype);
            goalMainStore.setDropDisplay(false)
        }
    }

    //设置收藏名称
    setCollection = (condtype,toptitle) =>{
        let collectParams = {
            favname: toptitle,
            favouritetype: 5,
            link: '/spa/workrelate/static/index.html?#/main/workrelate/goal/goalIndex?condtype='+condtype,
            importantlevel: 1,
        }
        this.setState({collectParams})
    }

    showColumn = () => {    //显示列定制
        const {goalMainStore: { tableStore }} = this.props
        tableStore.setColSetVisible(true)
        tableStore.tableColSet(true)
    }

    //切换视图展示方式
    onDataShowTypeChange = (dataShowType) => {
        const { changeDataShowType, getGoalList } = this.props.goalMainStore
        changeDataShowType(dataShowType)
        getGoalList({})
    }

    //视图切换
    onSortcondClick(type) {
        const { goalMainStore } = this.props;
        goalMainStore.sortcond = type;
        if(type == 3 || type == 4){
            goalMainStore.changeDataShowType(1)
        }
        if (type == 4) {
            this.setIfreamSrc();
        } else {
            this.setState({ searchType: ["advanced", "base"] });
            goalMainStore.getGoalList({});
        }

    }

    //新增页面 编辑页面成功回调
    onCallBackSuccess(optparams, type, openSide, pgId) {
        const { goalMainStore, goalCommonStore } = this.props;
        const { sortcond, canCreate, condtype } = goalMainStore;
        if (!Util.isEmpty(pgId)) {
            this.setIfreamSrc(pgId)
        } else {
            if (type == 1) {
                this.onCloseSlideModal();
            } else if (type == 2) {
                goalMainStore.setDataList(optparams) //更新list数据
                if (goalMainStore.dataShowType == "2") {
                    this.reloadCurrentPage()
                } 
            }else if(type == 3){ //详情更新  上级目标 责任人 参与人 日期 分类  描述 回调
                if (goalMainStore.dataShowType == "2") {
                    this.reloadCurrentPage()
                } 
            } else {
                if (goalMainStore.dataShowType == "2") {
                    this.reloadCurrentPage()
                    return;
                } 
                if(condtype != "9"){  //如果是负责人在分享给我的组织目标维度下创建，则不更新列表
                    goalMainStore.setNewGoalInfo(optparams);
                }
                if (optparams.opttype == 'add' || openSide) {   //openSize  列表新建,侧边打开参数
                    let _refeshid = -1;
                    if (this.state.refeshid == -1) {
                        _refeshid = 0;
                    }
                    goalMainStore.slidevisible = true;
                    const { _top } = this.state;
                    goalCommonStore.setIsFocusFeedBack(false);
                    this.resetUrlKey();
                    this.setState({ slidevisible: true, content: <GoalDetail ecId={`${this && this.props && this.props.ecId || ''}_GoalDetail@isvato`} detailKey={optparams.datas[0].key} refeshid={_refeshid} minusHeight={_top} onEditSuccess={(arry, type) => this.onCallBackSuccess(arry, type)} sortcond={sortcond} closeSlider={() => this.onCloseSlideModal()} locationKey={new Date().getTime()} />, refeshid: _refeshid, createvisable: false });
                }
                if (optparams.opttype == 'del') {
                    this.onCloseSlideModal();
                }
            }
        }

    }

    //关闭右边弹出框
    onCloseRightWindow() {

    }

    //目标导入
    onGoalImport = () =>{
        const { setShowImport } = this.props.goalCommonStore;
        setShowImport(true);
    }

    //目标导出
    onGoalExport = () =>{
        const { setShowExport } = this.props.goalCommonStore;
        setShowExport(true);
    }

    //快捷创建目标
    onAddGoal(type, v, idx, e) {
        this.resetUrlKey();
        const { goalMainStore, goalCommonStore } = this.props
        const { orgId, typeId, condtype } = goalMainStore;
        const { _top, refeshid } = this.state;
        let date = Util.computeEndDate(goalMainStore.currentperiod)
        if (type == -2) {
            this.setState({ createvisable: true, pgid: v });
        } else {
            if(Util.isBlank(v)){
                return;
            }
            if (v != "") {
                if (goalMainStore.sortcond == 1) {
                    goalMainStore.addname = v;
                }
                let _refeshid = -1;
                if (refeshid == -1) {
                    _refeshid = 0;
                }
                goalMainStore.addGoal({
                    cate: type, goalName: v, index: idx, enddate: date, period: goalMainStore.currentperiod,orgId: orgId,typeId: typeId,condtype: condtype, doback: (goalid) => {
                        goalCommonStore.setIsFocusFeedBack(false);
                        this.setState({ slidevisible: true, content: <GoalDetail ecId={`${this && this.props && this.props.ecId || ''}_GoalDetail@gjmncq`} detailKey={goalid} refeshid={_refeshid} minusHeight={_top} onEditSuccess={(arry, type) => this.onCallBackSuccess(arry, type)} sortcond={goalMainStore.sortcond} closeSlider={() => this.onCloseSlideModal()} locationKey={new Date().getTime()} />, refeshid: _refeshid, createvisable: false });
                    }
                });
            }
        }
    }


    onEnterGoal(e, type, idx) {
        let keycode = e.keyCode;
        if (keycode == 13) {
            this.onAddGoal(type, e.target.value, idx);
        }
    }
    //下拉框改变事件
    onSelectChange(v, type) {
        const { goalMainStore } = this.props;
        const { condtype, sortcond } = goalMainStore;
        goalMainStore[type] = v;
        if(type == "currentOrgId"){
            this.onChangeOrgType(v)
        }else{
            if (sortcond == 4) {
                this.setIfreamSrc();
            } else {
                goalMainStore.getGoalList({});
            }
        }

    }

    //设置组织类型
    onChangeOrgType = (v) => {
        const { goalMainStore: { setTypeId, setOrgId, setOrgtitle, setOrgRight, setCanCreate, orgCardList, sortcond, getGoalList, condtype},goalCommonStore:{ setOrgData } } = this.props;
        setTypeId(orgCardList[v].type);
        setOrgId(orgCardList[v].orgId);
        setOrgtitle(orgCardList[v].orgName);
        setOrgData(condtype,orgCardList[v].type,orgCardList[v].orgId);
        if(orgCardList[v].canCreate){
            setCanCreate(true)
        }else{
            setCanCreate(false)
        }
        if(sortcond == 4){
            this.setIfreamSrc("");
        }else{
            getGoalList({});
        }
  
    }

    //层级视图ifream src变化
    setIfreamSrc(pgId) {
        const { goalMainStore } = this.props;
        const { currentperiod, nowyear, nowmonth, nowseason, condtype, typeId, orgId } = goalMainStore;
        if (!Util.isEmpty(pgId)) {
            this.setState({ searchType: [], iframeSrc: "/workrelate/goal/data/TreeShowNew.jsp?pgId=" + pgId + "&condtype=" + condtype + "&period=" + currentperiod + "&periody=" + nowyear + "&periodm=" + nowmonth + "&periods=" + nowseason + "&typeId=" + typeId + "&orgId=" + orgId });
        } else {
            this.setState({ searchType: [], iframeSrc: "/workrelate/goal/data/TreeShowNew.jsp?condtype=" + condtype + "&period=" + currentperiod + "&periody=" + nowyear + "&periodm=" + nowmonth + "&periods=" + nowseason + "&typeId=" + typeId + "&orgId=" + orgId });
        }
    }
    //搜索查询
    advanceSearch = (v)=> {
        const { goalMainStore } = this.props;
        this.setState({ showSearchAd: false });
        goalMainStore.getGoalList({});
    }
    //基础搜索框变化事件
    onSearchChange(v) {
        const { goalMainStore } = this.props;
        goalMainStore.searchname = v;
    }
    //点击查看目标明细
    onNodeClick(key, _refesh, sortcond) {
        const { goalCommonStore, goalMainStore } = this.props;
        const { loading } = goalMainStore;
        if(loading){
            return;   
        }
        goalCommonStore.setIsFocusFeedBack(false);
        this.resetUrlKey();
        this.setState({ slidevisible: true, content: <GoalDetail ecId={`${this && this.props && this.props.ecId || ''}_GoalDetail@k3cft5`} detailKey={key} minusHeight={this.state._top} onEditSuccess={(arry, type) => this.onCallBackSuccess(arry, type)} closeSlider={() => this.onCloseSlideModal()} refresh={_refesh} sortcond={sortcond} locationKey={new Date().getTime()} /> });
    }
    //列表右侧图标点击事件
    onRightBtnClick(key, element, comsbtn, _refesh,_tags,cb) {
        let type = element.type;
        if (type) {
            const { goalMainStore, goalCommonStore } = this.props;
            const { sortcond, condtype } = goalMainStore;
            if (type == "complete") { //标记完成
                Modal.confirm({
                    title: getLabel(15172, '系统提示'),
                    content: getLabel(508754, '确认标记完成吗'),
                    onOk: () => {
                        goalMainStore.toChangeStatus({ "goalId": key, "status": 2, condtype ,"comsbtn": comsbtn, "type": type, doback:()=>{
                            message.success(getLabel(31439,'更新成功!'), 2);
                            typeof cb === "function" && cb()
                        }});
                    },

                });
            } else if (type == "progress" || type == "redo") { //标记进行
                Modal.confirm({
                    title: getLabel(15172, '系统提示'),
                    content: getLabel(508755, '确认标记进行吗'),
                    onOk: () => {
                        goalMainStore.toChangeStatus({ "goalId": key, "status": 1, condtype , "comsbtn": comsbtn, "type": type, doback:()=>{
                            message.success(getLabel(31439,'更新成功!'), 2);
                            typeof cb === "function" && cb()
                        }});
                    },

                });
            } else if (type == "special") { //关注
                goalMainStore.setSpecial({ "goalId": key, "special": 1, condtype ,"comsbtn": comsbtn, "type": type, doback:()=>{
                    message.success(getLabel(503769,'关注成功!'), 2);
                    typeof cb === "function" && cb()
                }});

            } else if (type == "canclespecial") { //取消关注
                goalMainStore.setSpecial({ "goalId": key, "special": 0, condtype , "comsbtn": comsbtn, "type": type, doback:()=>{
                    message.success(getLabel(503772,'取消关注成功!'), 2);
                    typeof cb === "function" && cb()
                }});
            } else if (type == "delete") { //删除
                Modal.confirm({
                    title: getLabel(15172, '系统提示'),
                    content: getLabel(127574, '确定删除吗？'),
                    onOk: () => {
                        goalCommonStore.editStatus({"goalId": key, status: "4", condtype, doback:()=>{
                            let optparams = {};
                            optparams.optkey = key;
                            optparams.opttype = 'del';
                            this.onCallBackSuccess(optparams)
                            typeof cb === "function" && cb()
                        }})
                    },
                });
            } else if(type == "tag"){ //标记标签
                if(_tags){
                    goalMainStore.checkedIds = _tags.map((d, i) => d.id);
                }
                this.onTagSet(true,2,key);
            } else {
                this.onAddFeebback(key);
            }
        }
    }

    deleteGoal = (id) => {
        const { goalCommonStore, goalMainStore:{condtype} } = this.props;
        let params = {
            goalId: id,
            status: '4',
            condtype,
            doback: () => {
                let optparams = {};
                optparams.optkey = id;
                optparams.opttype = 'del';
                this.onCallBackSuccess(optparams)

            }
        }
        goalCommonStore.editStatus(params)
    }


    //查看更多
    showMore(e, idx, _total, _pagenum, tid) {
        const { goalMainStore } = this.props;
        const { condtype, orgId, typeId } = goalMainStore;
        goalMainStore.getGoalMoreList({ index: idx, pagenum: parseInt(_pagenum) + 1, total: _total, cate: tid, condtype, orgId, typeId});
    }

    //新建dialog框保存
    doSubmit=()=> {
        this.refs.addgoalref.wrappedInstance.doNewSave();
    }
    //新建dialog框关闭
    onlyClose=(optparams)=> {
        if (optparams) {
            const { goalMainStore } = this.props;
            const { condtype, sortcond } = goalMainStore;
            if (optparams.optkey) {
                if (condtype == 2 || (condtype == 1 && sortcond == 4)) {
                    this.setIfreamSrc();
                }
            }
        }
        this.setState({ createvisable: false });
    }
    getButton = () => {
        let buttonsCreate = [
            (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@xjwfeg@save`} type="primary" onClick={this.doSubmit}>{getLabel(86, '保存')}</Button>),
            (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@zdrzzm@close`} type="ghost" onClick={this.onlyClose}>{getLabel(309, '关闭')}</Button>)
        ];
        return buttonsCreate;
    }
    //高级搜索页面按钮
    getTabButtonsAd() {
        return [
            (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@cs2amj@search`} type="primary" onClick={this.advanceSearch}>{getLabel(197, '搜索')}</Button>),
            (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@6lukux@reset`} type="ghost" onClick={this.resetSearchAd}>{getLabel(2022, '重置')}</Button>),
            (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@zlu22c@cancel`} type="ghost" onClick={this.cancleSearchAd}>{getLabel(31129, '取消')}</Button>)
        ]
    }
    //重置
    resetSearchAd=()=> {
        const { goalMainStore } = this.props;
        goalMainStore.resetSearchOption()
    }
    //关闭高级搜索
    cancleSearchAd= ()=>{
        // const { goalMainStore } = this.props;
        this.setState({ showSearchAd: false });
        // goalMainStore.resetSearchOption()
    }
    //高级搜索条目
    getSearchsAd() {
        const { orderData, orderByData } = this.state;
        const { goalMainStore } = this.props;
        const { searchname, orderby, orderbytype, principalid, enddate, enddate1, tag } = goalMainStore;
        let items = [];
        items.push({ com: <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@lyz8m2@goalname`} label={getLabel(18238, '目标名称')} ratio1to2><WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@ojvhp3@goalname`} value={searchname} onChange={(value) => this.onAdvancedChange(value, 'searchname')} onPressEnter={() => this.advanceSearch()} /></WeaFormItem> });
        items.push({
            com: <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@x1senf@principalid`} label={getLabel(16936, '责任人')} ratio1to2><WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@d4lfz7@principalid`} type={1} replaceDatas={toJS(principalid)}
                onChange={(ids, names, datas) => this.onAdvancedChange(datas, "principalid")} title={getLabel(16936, '责任人')} /></WeaFormItem>
        });
        items.push({
            com: <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@6mgopv@enddate`} label={getLabel(741, '结束日期')} ratio1to2>
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@uwaiom@enddate`}>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@pynfla@enddate`} span={11} > <WeaDatePicker ecId={`${this && this.props && this.props.ecId || ''}_WeaDatePicker@07uv91@enddate`} value={enddate} onChange={value => this.onAdvancedChange(value, "enddate")} /></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@jsx40w@enddate2`} span={2}></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@e1r6g7@enddate1`} span={11}><WeaDatePicker ecId={`${this && this.props && this.props.ecId || ''}_WeaDatePicker@4mri2s@enddate1`} value={enddate1} onChange={value => this.onAdvancedChange(value, "enddate1")} /></Col>
                </Row>
            </WeaFormItem>
        });
        items.push({
            com: <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@cgmg16@orderby`} label={getLabel(129216, '排序方式')} ratio1to2>
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@lhq1vi@orderby`}>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@7a9wda@orderby`} span={11}><WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@vh22y0@orderby`} options={orderData} viewAttr={2} value={orderby} onChange={v => this.onAdvancedChange(v, "orderby")} /></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@ixyy0m@orderby1`} span={2}></Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@jl4bbl@orderbytype`} span={11}><WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@54dlvw@orderbytype`} options={orderByData} viewAttr={2} value={orderbytype} onChange={v => this.onAdvancedChange(v, "orderbytype")} /></Col>
                </Row>
            </WeaFormItem>
        });
        return <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@15ajtf`} title={getLabel(32905, '常用条件')} items={items} showGroup={true} col={2} />
    }
    //高级搜索界面组件变化事件
    onAdvancedChange(v, type) {
        const { goalMainStore } = this.props;
        let flag = true;
        if(type=="enddate" && goalMainStore.enddate1!="" && Util.DateDiffDays(v,goalMainStore.enddate1)<0){
           flag = false;
        }
        if(type=="enddate1" && goalMainStore.enddate!="" && Util.DateDiffDays(v,goalMainStore.enddate)>0){
           flag = false;
        }
        if(!flag){
            message.warning(getLabel(518654,'日期选择有误'));
            goalMainStore[type] = v;
            goalMainStore[type] = "";
            return;
        }
        goalMainStore[type] = v;
    }
    onCloseSlideModal=()=> {//关闭右侧弹出框
        this.setState({ slidevisible: false });
    }
    onTopClick(e) {//点击隐藏右边弹出框
        const { slidevisible } = this.state;
        if (slidevisible) {
            this.setState({ slidevisible: false });
        }
    }
    resetUrlKey() {
        //弹框更改url上的_key值
        const { pathname, search } = this.props;
        let url = `/${pathname}${search}`;
        if (pathname == undefined || search == undefined) {
            url = "/main/workrelate/goal/goalIndex";
        }
        this.context.router.push({
            pathname: url
        });
    }

    /**
     * 获取顶部按钮和右键菜单
     */
    getTopButtonMenu = () => {
        const { goalMainStore: { condtype, canCreate, dropdisplay, sortcond, datalist, dataShowType, loading } } = this.props;
        const { buttons, menu, dropData, dropSelectedKey } = this.state;
        let _menu = [];
        let _button = [];
        if(loading){
            return [_button,_menu];
        }else{
            if (!canCreate) { //无权创建
                _menu.push(menu[0]);
            }else {
                _button = [];
                if( condtype != 9){
                    _button.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@7wbzux@newgoal`} placement="bottom" title={getLabel(508587, '新建目标')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ctbp36@newgoal`} type='primary' onClick={() => this.onAddGoal(-2)}>{getLabel(82, '新建')}</Button></Tooltip>);
                    _menu.push(menu[0]);
                    _menu.push(menu[1]);
                }
                if(condtype != 2 && condtype != 8 && condtype != 9 ){
                    _button.push(<Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@sobyp3@importdata`} placement="bottom" title={getLabel(32935,'导入')}><Button ecId={`${this && this.props && this.props.ecId || ''}_Button@tywke3@importdata`} type='primary' onClick={() => this.onGoalImport()}>{getLabel(32935,'导入')}</Button></Tooltip>);
                    _menu = menu;
                }
            }
            _button.push(<ButtonSelect ecId={`${this && this.props && this.props.ecId || ''}_ButtonSelect@ymkjzv@batchbtn`} datas={dropData} btnProps={{ disabled: dropdisplay }} selectedKey={dropSelectedKey} btnOnClick={(key) => this.btnOnClick(key)} menuOnClick={(key) => this.onDropMenuClick(key)} />);
            _menu =  _menu.concat(this.getMenu(sortcond,dataShowType));
            return [_button,_menu];
        }   
    }

    //获得分页显示的右键
    getMenu = (sortcond, dataShowType) =>{
        let _menu = [];
        if (sortcond == "1") {
            if (dataShowType == "2") {
                _menu = _menu.concat([
                    {
                        key: '3',
                        icon: <i className="icon-coms-task-list" />,
                        content: getLabel('81640','滚动显示'),
                        onClick: () => this.onDataShowTypeChange("1")
                    },
                    {
                        key: '4',
                        icon: <i className='icon-coms-Custom'/>,
                        content: getLabel(32535,'显示列定制'),
                        onClick: this.showColumn
                    }
                ])
            } else {
                _menu.push({
                    key: '5',
                    icon: <i className="icon-coms-form" />,
                    content: getLabel('517579','分页显示') ,
                    onClick: () => this.onDataShowTypeChange("2")
                })
            }
        }
        return _menu;
    }

    //处理选择框和单个标签删除
    treeOtherClick(key,_v,type,currentid,cb){
        const { goalMainStore } = this.props;
        if(type=='deltag'){
            goalMainStore.editGoalTag({fieldvalue:_v,fieldname:"tag",goalId:key,tagtype:"1",logDelvalue:_v,doback:function(){
                message.success(getLabel(83472,'删除成功!'), 2);
                typeof cb === "function" && cb()
            }});
        }else if(type=='checkbox'){
            let isSelect = Util.isSelectCheckBox(goalMainStore.datalist,_v);
            let isallselect = Util.isAllSelectCheckBox(goalMainStore.datalist,"0",currentid);//是否全选
            goalMainStore.setAllCheckBoxValue(isallselect?"1":"0",currentid);
            goalMainStore.setDropDisplay(isSelect);
        }
    }

    //打开标签设置框
    onTagSet(v, _type, _key) {
        this.setState({ tagvisable: v, opentagtype: _type, selectgoalid: _key });
    }

    //顶部按钮批量操作
    btnOnClick = (key) => {
        const { goalMainStore } = this.props;
        const { condtype, tableSelectedRowKeys, dataShowType  } = goalMainStore;
        if (key == 1) {//批量操作
            let goalIds = "";
            if (dataShowType == "2") {
                goalIds = tableSelectedRowKeys.join(",")
            }else{
                goalIds = Util.getDataListIds(goalMainStore.datalist, true, goalMainStore.sortcond);
            }
            if (goalIds == "") {
                message.warning(getLabel(501159, '请选择要操作的数据'));
                return;
            }
            Modal.confirm({
                title: getLabel(131329, '信息确认'),
                content: getLabel(513503, '确认要删除选中记录吗？'),
                onOk() {
                    goalMainStore.batchDelGoal({
                        goalIds,condtype,doback: function (status) {
                            if (status) {
                                message.success(getLabel(83472, '删除成功!'), 2);
                                goalMainStore.setDropDisplay(false)
                            }
                        }
                    });
                },
                onCancel() { },
            });
        } else {
            goalMainStore.checkedIds = "";
            this.onTagSet(true, 1);
        }
    }

    //选中全部
    checkAll(v, currentid) {
        const { goalMainStore } = this.props;
        let { datalist, sortcond } = goalMainStore;
        goalMainStore.refreshlist = false;
        Util.setDataCheckBoxValue(datalist, v, currentid, sortcond, this.state.dropSelectedKey);
        goalMainStore.datalist = datalist;
        goalMainStore.setAllCheckBoxValue(v,currentid);
        goalMainStore.setDropDisplay(Util.isSelectCheckBox(datalist, v));
        goalMainStore.refreshlist = true;
    }

    /**
     * 批量操作表钱
     * @param {*} key 
     * @param {*} checklist 
     */
    checkList = (key,checklist)=>{
        const {goalMainStore} = this.props;
        let {opentagtype,selectgoalid} = this.state;
        let { dataShowType, tableSelectedRowKeys } = goalMainStore
        let goalids= "";
        if (dataShowType == "2") {
            if (opentagtype == 1) {
                goalids = tableSelectedRowKeys.join(",")
            } else {
                goalids = selectgoalid
            }
        } else{
            if(opentagtype==1){//获取批量的目标id
                goalids = Util.getDataListIds(goalMainStore.datalist,false,goalMainStore.sortcond);
            }else{
                goalids = selectgoalid; //当前点击选中的目标id
            }
        }
        if(goalids==""){
            message.warning(getLabel(501159, '请选择要操作的数据'));
            return;
        }
        this.onTagSet(false,1);
        if(key=="0"){//清除
            let _title = opentagtype==1?getLabel(516448, "确定要清除选中数据的所有标签吗？"):getLabel('516445','确认清除所有标签吗？');
            Modal.confirm({
                title: getLabel(386786, '信息确认'),
                content: _title,
                onOk: () => {
                    goalMainStore.editGoalTag({fieldname:"tag",goalids,tagtype:"3",doback:(status)=>{
                        if(status){
                            message.success(getLabel(31439, '更新成功!'), 2);
                            goalMainStore.setDropDisplay(false)
                        }
                    }});
                }
            })
        }else if(key=="1"){//确定
            let newIdsStr = checklist.map((d, i) => d.id).join(",");
            goalMainStore.editGoalTag({fieldvalue:newIdsStr,fieldname:"tag",goalids,tagtype:"2",opentagtype,doback:(status)=>{
                message.success(getLabel(31439, '更新成功!'), 2);
                goalMainStore.setDropDisplay(false)
            }});
        }
    }

    closeShareForm = () =>{
        this.setState({orgShareVisiable:false})
    }

    orgGoalShareSetting = () =>{
        this.setState({orgShareVisiable:true})
    }

    getOrgGoalShareButtons = () =>{
        let buttons = [
            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@2osv6n@shareclose`} type="ghost" onClick={this.closeShareForm}>{getLabel(309, '关闭')}</Button>
        ];
        return buttons;
    }
    onTagSelectChange = (tagList) => {
        const { goalMainStore } = this.props;
        let ckids = tagList.reduce((ids, elem) => {
            ids += elem.id + ",";
            return ids;
        }, "");
        ckids = ckids.endsWith(",") ? ckids.substring(0, ckids.length - 1) : ckids;
        goalMainStore.tag = ckids;
        goalMainStore.getGoalList({});
    };

    //导入的回调函数
    importGoalBack = () =>{
        const { goalMainStore } = this.props;
        goalMainStore.getGoalList({});
    }

    reloadCurrentPage = () => {
        const { tableStore } = this.props.goalMainStore;
        tableStore.reloadCurrent()
    }

    onTableGoalTagClose = (e, goalid, deltagid) => {
        e.preventDefault()
        e.stopPropagation()
        this.treeOtherClick(goalid, deltagid, "deltag", null, this.reloadCurrentPage.bind(this))
    }

    onDropMenuClick = (key) => {
        const { goalMainStore } = this.props
        this.setState({dropSelectedKey: key})
        goalMainStore.isBatchDel = key == "1"
        if (goalMainStore.dataShowType == "2") {
            goalMainStore.getGoalList({isReloadCurrent: true})
        }
    }

    //重写table的列
    getTableColumns = (columns) => {
        return columns.map(col => {
            if (col.dataIndex != "name" ) {
                col = {...col, width: 130}
            }
            
            if (col.dataIndex == "id") {
                return {...col, display: false}
            } else if (col.dataIndex == "name" || col.dataIndex == "parentid") {
                return {
                    ...col,
                    render: (text, record, index) => {
                        let m = JSON.parse(record[col.dataIndex + "span"])
                        return (
                            <div className="colomn-taskname-wrapper" style={col.dataIndex == "name" ? {cursor: "pointer"} : {}} title={m.name} onClick={e => {
                                if (col.dataIndex == "name") {
                                    e.stopPropagation()
                                    e.nativeEvent.stopImmediatePropagation()
                                    this.onNodeClick(m.id)
                                }
                            }}>
                                <div className="task-text">{m.name}</div>
                                <div className="task-tag">
                                    {
                                        m.tags && m.tags.map(tag => {
                                            return (
                                                <span className="tag-item-wrapper">
                                                    <WeaTag ecId={`${this && this.props && this.props.ecId || ''}_WeaTag@n06sa9@${tag.id}`} color={tag.color} title={tag.name} closable={true} onClose={e => this.onTableGoalTagClose(e, record.id, tag.id)} ref={ref => {
                                                        if (ref) {
                                                            let dom = ReactDOM.findDOMNode(ref)
                                                            dom.parentNode.style.width = dom.clientWidth + 15 + "px"
                                                        }
                                                    }}>{tag.name}</WeaTag>
                                                </span>
                                            )
                                        })
                                    }
                                </div>
                            </div>
                        )
                    }
                }
            } 
            return col
        })
    }

    onTableOperatesClick = (event, record, btn, comsbtn, tags) => {
        if (btn.type == "addfb") {
            event.stopPropagation()
            this.onAddFeebback(record.id);
            // this.onNodeClick(record.id, "1")
        } else {
            this.onRightBtnClick(record.id, btn, comsbtn,true,tags, this.reloadCurrentPage.bind(this))
        }
    }

    //添加反馈
    onAddFeebback = (id) =>{
        const { goalCommonStore, goalMainStore:{ sortcond }  } = this.props;
        this.resetUrlKey();
        goalCommonStore.setIsFocusFeedBack(true);
        this.setState({ slidevisible: true, content: <GoalDetail ecId={`${this && this.props && this.props.ecId || ''}_GoalDetail@uucsze`} detailKey={id} minusHeight={this.state._top} onEditSuccess={(arry, type) => this.onCallBackSuccess(arry, type)} closeSlider={() => this.onCloseSlideModal()}  locationKey={new Date().getTime()} sortcond={sortcond} /> });
    }

    getCustomOperates = (record, index, operates) => {
        const comsbtn = JSON.parse(record.comsbtnspan)
        const tags = JSON.parse(record.namespan).tags
        return (
            <Menu ecId={`${this && this.props && this.props.ecId || ''}_Menu@g4qdhp`}>
                {
                    comsbtn.reverse().map(btn => {
                        return (
                            <Menu.Item ecId={`${this && this.props && this.props.ecId || ''}_Menu.Item@h7kdtb@${btn.type}`}>
                                <div 
                                    ref={ref => {
                                        if (ref) {
                                            ref.onclick = (e) => {
                                                this.onTableOperatesClick(e, record, btn, comsbtn, tags)
                                            }
                                        }
                                    }}
                                >
                                    {
                                        btn.com
                                    }
                                </div>
                            </Menu.Item>
                        )
                    })
                }
            </Menu>
        )
    }

    onTableSelectChange = (ids, records) => {
        this.props.goalMainStore.tableSelectedRowKeys = ids
        this.props.goalMainStore.setDropDisplay(ids.length !== 0)
    }

    //获取标题名称
    // getTopTitle = (condtype) =>{
    //     let map = new Map();
    //     map.set("1",getLabel(18028,"我的目标"));
    //     map.set("2",getLabel(518141,"组织目标"));
    //     map.set("3",getLabel(506156,"我创建的目标"));
    //     map.set("4",getLabel(506157,"我参与的目标"));
    //     map.set("5",getLabel(506159,"分享给我的目标"));
    //     map.set("6",getLabel(506158,"我关注的目标"));
    //     map.set("8",getLabel(506156,"我创建的目标"));
    //     map.set("9",getLabel(506159,"分享给我的目标"));
    //     map.set("10",getLabel(520928,"目标导出"));
    //     return map.get(condtype);
    // }

    render() {
        const { goalMainStore, goalCommonStore ,toptitle } = this.props;
        const { showImport, showExport } = goalCommonStore;
        const { searchname, loading, yeardata, nowyear, nowmonth, monthdata, datetype, seasondata, nowseason, currentperiod, currentstatus, hasmore, sortcond, datalist, optparams, localtime, refreshlist, pagenum, itotal, canCreate, addname, refreshDetail, isShowType, principaler, checkedIds, allCheckBoxVal, orgTypeList, currentOrgId, orgId, typeId, condtype, orgtitle, tag, tableStore, dataShowType, refreshTable} = goalMainStore;
        const { periodData, statusData, _top, menuid, createvisable, showSearchAd, iframeSrc, searchType, slidevisible, content, pgid, tagvisable, dropSelectedKey, collectParams, orgShareVisiable} = this.state;
        let quickCreate = false;
        if(canCreate && menuid != 9 ){
            quickCreate = true;
        }
        if ((menuid == 2 || menuid == 8) && orgTypeList.length == 0) {
            return (
                <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@jfwus6`} spinning={loading}>
                    <div>
                        <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@md2nhh`}
                            title={<span>{toptitle ? toptitle : getLabel(518141,"组织目标")}</span>}
                            icon={<i className='icon-coms-implement' />}
                            iconBgcolor='rgb(150, 53, 138)'
                        >
                        </WeaTop>
                        {Util.renderAlertPage(menuid == 2?getLabel(518694, '暂未设置组织目标'):getLabel(2012,'对不起，您暂时没有权限！'),'','','',this.props.ecId || '')}
                    </div>
                </Spin>
            )
        }
        return (
            <div className="wea-workrelate-goal-main">
                <div onClick={(e) => this.onTopClick(e)}>
                    <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@0cfw5a`} datas={this.getTopButtonMenu()[1]} showUrlItem={false} style={{ height: '100%' }}  collectParams={collectParams} >
                        <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@8bqlyd`}
                            title={condtype == 2 ? (getLabel(518141,"组织目标") +":"+orgtitle) : (toptitle || getLabel(18028, '我的目标'))  }
                            icon={<i className="icon-coms-implement" />}
                            iconBgcolor='rgb(150, 53, 138)'
                            buttons={this.getTopButtonMenu()[0]}
                            showDropIcon={true}
                            dropMenuDatas={this.getTopButtonMenu()[1]}
                        />
                        {/* {menuid == 2 && orgTypeList.length == 0 && Util.renderAlertPage(getLabel(518694,'暂未设置组织目标'))} */}
                        <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@eykx44`} spinning={loading}>
                            <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@s3i6tp`}
                                searchType={searchType}
                                showSearchAd={showSearchAd}
                                hideSearchAd={this.cancleSearchAd}
                                advanceHeight={200}
                                setShowSearchAd={bool => {
                                    this.setState({ showSearchAd: bool });
                                }}
                                searchsBaseValue={searchname}
                                replaceLeft={<div className="goal-main-condition">
                                    <div className="goal-main-condition-right">
                                        <div className="goal-main-icon-div">
                                            {(menuid == 1 || menuid == 2) && <Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@j0qvr4`} placement="bottom" title={getLabel(382496, '层级视图')}><i className={sortcond == 4 ? "icon-coms-Department-number iconselected" : "icon-coms-Department-number"} onClick={(e) => this.onSortcondClick(4)} /></Tooltip>}
                                            <Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@dpvxrf`} placement="bottom" title={getLabel(508756, '分类视图')}><i className={sortcond == 3 ? "icon-coms-category iconselected" : "icon-coms-category"} onClick={(e) => this.onSortcondClick(3)} /></Tooltip>
                                            <Tooltip ecId={`${this && this.props && this.props.ecId || ''}_Tooltip@2o24jx`} placement="bottom" title={getLabel(82532, '列表视图')}><i className={sortcond == 1 ? "icon-coms-Right-alignment iconselected" : "icon-coms-Right-alignment"} onClick={(e) => this.onSortcondClick(1)} /></Tooltip>
                                        </div>
                                        {(menuid == 2 || menuid == 8)  && orgTypeList.length > 0 && <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@jke9eq`} options={orgTypeList} value={currentOrgId} detailtype={5}  viewAttr={2} style={{ width: 80, marginRight: 10 }} onChange={v => this.onSelectChange(v, "currentOrgId")} />}
                                        {sortcond != 4 && <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@dnzcc8`} className="goal-main-condition-space" options={statusData} detailtype={5} value={currentstatus} viewAttr={2} style={{ width: 80 }} onChange={v => this.onSelectChange(v, "currentstatus")} />}
                                        {/* <div className="goal-main-condition-space"></div> */}
                                        { <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@50gh0n`} options={periodData} detailtype={5} value={currentperiod} viewAttr={2} style={{ width: 80, marginRight: 10 }} onChange={v => this.onSelectChange(v, "currentperiod")} />}
                                    </div>
                                    {(currentperiod == 1 || currentperiod == 2 || currentperiod == 3) && <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@cwbjsi`} options={toJS(yeardata)} value={nowyear} viewAttr={2} style={{ width: 80, marginRight: 10 }} onChange={v => this.onSelectChange(v, "nowyear")} />}
                                    {currentperiod == 1 && <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@7nzkm7`} options={toJS(monthdata)} value={nowmonth} viewAttr={2} style={{ width: 80, marginRight: 10 }} onChange={v => this.onSelectChange(v, "nowmonth")} />}
                                    {currentperiod == 2 && <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@c0j1q1`} options={toJS(seasondata)} value={nowseason} viewAttr={2} style={{ width: 80, marginRight: 10 }} onChange={v => this.onSelectChange(v, "nowseason")} />}
                                    {/* {menuid == 2 && canCreate && <Tooltip placement="bottom" title={getLabel(383654,'共享列表')} ><span style={{ marginLeft: "10px", cursor: "pointer" }} >
                                        <i className="icon-coms-Flow-setting" onClick={() => this.orgGoalShareSetting()} />
                                    </span></Tooltip>} */}
                                    {sortcond != 4 && <TagSelectBox ecId={`${this && this.props && this.props.ecId || ''}_TagSelectBox@af36qr`} onCallBack={this.onTagSelectChange} value={tag} />}  
                                </div>}
                                buttonsAd={this.getTabButtonsAd()}
                                onSearch={() => this.advanceSearch()}
                                onSearchChange={(v) => this.onSearchChange(v)}
                                searchsAd={this.getSearchsAd()}
                            />
                            <div style={{ height: window.innerHeight - 120 - _top }}>
                                {dataShowType == 1 && <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@6uk51l`} height={window.innerHeight - 120 - _top}>
                                    {(sortcond == 4 && (menuid == 2 || menuid == 1)) && <iframe id="modelView" name="modelView" scrolling="auto"
                                        style={{ border: "none" }} src={iframeSrc} width='100%' height={window.innerHeight - 100 - _top}></iframe>
                                    }
                                    <div>
                                        {sortcond == 1 && <div className="workrelate-goal-checkboxall"><WeaCheckbox ecId={`${this && this.props && this.props.ecId || ''}_WeaCheckbox@fpemyu`} value={allCheckBoxVal} content={getLabel(556, '全选')} onChange={(v) => this.checkAll(v)} /></div>}
                                        {sortcond == 1 && refreshlist && <div className="goal-main-content">
                                        <WeaNewScrollPagination ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScrollPagination@t6u0at`} height={Math.min(window.innerHeight-120-_top, 760) - 110} onScrollEnd={(e) => { hasmore == 2 && this.showMore(e, 0, itotal, pagenum) }}>
                                        <ViewTree ecId={`${this && this.props && this.props.ecId || ''}_ViewTree@kmrwvl`} className="goal-main-vt" datas={datalist} params={optparams} locationkey={localtime}
                                            onRightBtnClick={(key, element, comsbtn, otherInfo, _tag) => this.onRightBtnClick(key, element, comsbtn, otherInfo, _tag)} onTreeNodeClick={(key) => this.onNodeClick(key, refreshDetail, sortcond)}
                                            onOtherClick={(key, _v, _type) => this.treeOtherClick(key, _v, _type)} boxProp={dropSelectedKey}
                                        />
                                        </WeaNewScrollPagination>
                                         </div>
                                        }
                                        {sortcond == 1 && quickCreate && <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@h1rdhi`} ref='quickCreate' className="add-intext" placeholder={getLabel(508759, '快速新建目标')} value={addname} onBlur={val => this.onAddGoal('', val)} onPressEnter={(e) => this.onEnterGoal(e, '')} onFocus={(value) => this.onCloseRightWindow()} />
                                        }
                                        {/* {
                                            sortcond == 1 && (hasmore && hasmore == 2 ? <div className="goal-main-more" onClick={e => this.showMore(e, 0, itotal, pagenum, 0)}>{getLabel(82720, '加载更多')}<Icon type="down" /></div>
                                                : <div className="goal-main-nodata">{hasmore == 3 ? getLabel(508761, '已加载所有目标') : getLabel(83553, '已加载所有目标')}</div>)
                                        } */}
                                    </div>
                                    {
                                        refreshlist && sortcond == 3 && datetype && datetype.length > 0 && datetype.map((element, idx) => {
                                            return <ViewSort ecId={`${this && this.props && this.props.ecId || ''}_ViewSort@1s2msg@${element.id}`} title={<span><span className="workrelate-goal-checkboxall-d"><WeaCheckbox ecId={`${this && this.props && this.props.ecId || ''}_WeaCheckbox@iwetyu@${element.id}`} value={element.allCheckBoxVal} onChange={(v) => this.checkAll(v, element.id)} /></span><i className={element.icon} style={{ color: element.color }} /><span className="goal-main-viewsort-titlename">{element.name}</span></span>} className="goal-main-viewsort" style={{ borderLeft: `2px solid ${element.color}`, backgroundColor: "#F3F3F4" }} >
                                                {<ViewTree ecId={`${this && this.props && this.props.ecId || ''}_ViewTree@44rsle@${element.id}`} className={isShowType && element.hasdata && element.hasdata == 1 ? "goal-main-vt" : ""} datas={datalist} params={optparams} locationkey={localtime} treetype={"m" + element.id}
                                                    onRightBtnClick={(key, element, comsbtn, otherInfo, _tag) => this.onRightBtnClick(key, element, comsbtn, otherInfo, _tag)} onTreeNodeClick={(key) => this.onNodeClick(key, refreshDetail, sortcond)}
                                                    onOtherClick={(key, _v, _type) => this.treeOtherClick(key, _v, _type, element.id)} boxProp={dropSelectedKey} />}
                                                {quickCreate && <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@3eahvz@${element.id}`} ref='quickCreate' className="add-intext" placeholder={getLabel(508759, '快速新建目标')} value={element.inputval} onBlur={val => this.onAddGoal(element.id, val, idx)} onPressEnter={(e) => this.onEnterGoal(e, element.id, idx)} onFocus={(value) => this.onCloseRightWindow()} />}
                                                {element.hasmore == 2 && <div className="goal-main-more" onClick={e => this.showMore(e, idx, element.total, element.pagenum, element.id)}>{getLabel(82720, '加载更多')}<Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@qfoa50@${element.id}`} type="down" /></div>}
                                            </ViewSort>
                                        })
                                    }
                                </WeaNewScroll>
                                }
                                {
                                   refreshTable && dataShowType == 2 && sortcond == 1 &&
                                    <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@v70j04`}
                                        className="workrelate-task-main-table"
                                        comsWeaTableStore={tableStore}
                                        hasOrder
                                        needScroll
                                        rowSelection={this.rowSelection}
                                        getColumns={this.getTableColumns}
                                        customOperates={this.getCustomOperates}
                                    />
                                }
                            </div>
                        </Spin>
                    </WeaRightMenu></div>
                {<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@5udk5t`} visible={createvisable} title={getLabel(508587, '新建目标')} icon="icon-coms-implement" iconBgcolor="rgb(150, 53, 138)"
                    buttons={this.getButton()}
                    style={{ width: window.innerWidth * 0.7, height: window.innerHeight - 90 }} closable={true}
                    onCancel={this.onlyClose}>
                    {createvisable && <GoalAdd ecId={`${this && this.props && this.props.ecId || ''}_GoalAdd@ssxltf`} isDialog={true} height={window.innerHeight - 200} ref="addgoalref" doClose={(optparams) => this.onlyClose(optparams)} sortcond={sortcond} onAddSuccess={(arry, data, openSide, pgId) => this.onCallBackSuccess(arry, data, openSide, pgId)} principaler={principaler} period={currentperiod} nowyear={nowyear} locationKey={new Date().getTime()} pgId={pgid} />}
                </WeaDialog>}
                {tagvisable && <TagChoiceBox ecId={`${this && this.props && this.props.ecId || ''}_TagChoiceBox@8rbuga`} visible={tagvisable} checkedIds={checkedIds} onDialogClose={() => this.onTagSet(false, 1)} onCallBack={(key, checklist) => this.checkList(key, checklist)} />}
                <WeaSlideModal ecId={`${this && this.props && this.props.ecId || ''}_WeaSlideModal@kw7tbb`} visible={slidevisible}
                    width={60}
                    top={_top}
                    direction={'right'}
                    measure={'%'}
                    measureT={'px'}
                    content={(content)}
                    onClose={this.onCloseSlideModal} />
                {orgShareVisiable && <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@uuohey`}
                    icon='icon-coms-implement'
                    iconBgcolor='rgb(150, 53, 138)'
                    style={{ width: 840, height: 400 }}
                    buttons={this.getOrgGoalShareButtons()}
                    hasScroll
                    title={getLabel(383654,'共享列表')}
                    visible={orgShareVisiable}
                    onCancel={this.closeShareForm}
                >
                  {orgShareVisiable&& <GoalOrgShare ecId={`${this && this.props && this.props.ecId || ''}_GoalOrgShare@raw0tg`}></GoalOrgShare>} 
                </WeaDialog>}
                {showImport && <GoalImport ecId={`${this && this.props && this.props.ecId || ''}_GoalImport@fdwvka`} doback={()=>this.importGoalBack()}></GoalImport>}
            </div>
        )
    }
}